//
// Created by nilyang on 2022/2/19.
//

#ifndef BASIC_STL_TUPLE_ITERATION_H
#define BASIC_STL_TUPLE_ITERATION_H


/// tuple遍历implement （实现函数）（模板递归）
template <typename Tuple, typename Functor, int Index>
constexpr void foreach_tuple_via_recursive_template_impl(Tuple &&t, Functor &&f);

/// 遍历tuple（入口函数）（模板递归）
template <typename Tuple, typename Functor>
constexpr void foreach_tuple_via_recursive_template(Tuple &&t, Functor &&f);

/// 其中tuple语法
/// C++17 fold expression https://blog.csdn.net/K346K346/article/details/82150036
/// fold expression(since C++17) https://en.cppreference.com/w/cpp/language/fold
/// C++折叠表达式(Fold Expression) https://www.cnblogs.com/GEEK-ZHAO/p/15775026.html
/// 遍历tuple (实现函数)（折叠表达式（fold expression））
template<typename Tuple, typename Functor, size_t... Is>
constexpr void foreach_tuple_via_fold_expression_impl(Tuple &t, Functor &&f, std::index_sequence<Is...>);

/// 遍历tuple （入口函数）（折叠表达式（fold expression））
template<typename Tuple, typename Functor>
constexpr void foreach_tuple_via_fold_expression(Tuple &t, Functor &&f);


/// tuple 普通遍历 （模板递归）
void func_test_foreach_tuple_via_recursive_template();

/// 遍历tuple (测试函数)（折叠表达式（fold expression））
void func_test_foreach_tuple_via_fold_expression();

/// C++17 折叠展开
void func_test_recursive_and_fold_expression();

#endif //BASIC_STL_TUPLE_ITERATION_H
